@echo off
echo ============================================
echo 启动闲置换钱后端服务
echo ============================================

cd /d "%~dp0hao-cloud-api"

echo.
echo 1. 启动用户服务 (端口 5006)...
start "User API" cmd /k "dotnet run --project hao-Code/4.Api/hao-User.Api"

echo.
echo 2. 等待3秒后启动产品服务...
timeout /t 3 /nobreak >nul

echo.
echo 3. 启动产品服务 (端口 5233)...
start "Product API" cmd /k "dotnet run --project hao-Code/4.Api/hao-Product.Api"

echo.
echo 4. 等待3秒后启动API网关...
timeout /t 3 /nobreak >nul

echo.
echo 5. 启动API网关 (端口 5200)...
start "API Gateway" cmd /k "dotnet run --project hao-Gateway.Api"

echo.
echo ============================================
echo 所有服务启动中...
echo 用户服务: http://localhost:5006
echo 产品服务: http://localhost:5233  
echo API网关: http://localhost:5200
echo ============================================
echo.
echo 等待15秒后测试服务状态...
timeout /t 15 /nobreak >nul

echo.
echo 测试服务连通性...
curl -s http://localhost:5006/api/user/debug/consul-status >nul 2>&1 && echo "✅ 用户服务启动成功" || echo "❌ 用户服务启动失败"
curl -s http://localhost:5233/api/product/test >nul 2>&1 && echo "✅ 产品服务启动成功" || echo "❌ 产品服务启动失败"  
curl -s http://localhost:5200/api/user/debug/consul-status >nul 2>&1 && echo "✅ API网关启动成功" || echo "❌ API网关启动失败"

echo.
echo 现在可以启动前端应用了！
pause